//
//  TalkViewController.h
//  talkDemo
//
//  Created by telen on 15/4/17.
//  Copyright (c) 2015年 刘赞黄Telen. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <MediaPlayer/MediaPlayer.h>
#import <CoreMedia/CMBufferQueue.h>

#import "TalkRecordingView.h"
#import "PreviewView.h"
#import "VideoRecorder.h"

typedef enum : NSUInteger {
    TalkShareTo_none = 0,
    TalkShareTo_faceBook = 1,
    TalkShareTo_weibo,
    TalkShareTo_qq,
    TalkShareTo_wechat,
} TalkShareTo_type;
@protocol TalkVC_Delegate <NSObject>

@optional
- (BOOL)talkViewShareEnable__ShareTo:(TalkShareTo_type)shareto;
- (void)talkViewDidClicked_ShareTo:(TalkShareTo_type)shareto withInfo:(NSDictionary*)dict;
- (void)talkViewUploadedSuccess_withInfo:(NSDictionary*)dict;
- (void)talkViewDidClicked_Play;
//
- (BOOL)talkViewShareDefineMySelf:(UIView*)btnView withInfo:(NSDictionary*)dict;

@end


@interface TalkViewController : UIViewController <
AVCaptureVideoDataOutputSampleBufferDelegate,
AVCaptureAudioDataOutputSampleBufferDelegate,
AVCaptureFileOutputRecordingDelegate,
PreviewViewDelegate,
UIAlertViewDelegate
>
{
//    AVCaptureSession* captureSession;
//    AVCaptureMovieFileOutput* movieOutput;
//    AVPlayer* moviePlayer;
    
    PreviewView* previewView;
    //AVCaptureDeviceInput* videoInput;
    
    BOOL isCameraActive;
    BOOL isRecording;
    BOOL needToShare;
    AVCaptureSession* videoCaptureSession;
    AVCaptureAudioDataOutput* audioOutput;
    AVCaptureVideoDataOutput* videoOutput;
    CMBufferQueueRef videoBuffer;
    CMBufferQueueRef audioBuffer;
    float webcamWidth;
    float webcamHeight;
    NSTimeInterval recordingStarted;
    VideoRecorder* videoRecorder;
    CVImageBufferRef imageBuffer;
    NSTimeInterval startStamp;
    //
    NSDictionary* dict_UploadedInfo;
}

@property (nonatomic, strong) IBOutlet UIImageView* webcamView;

//@property(strong) AVPlayerLayer* moviePlayerLayer;

//MP4 save
@property(nonatomic,strong)NSString* saveVideoFullPath;      //use for save the record
@property(nonatomic,strong)NSString* saveVideoFullPath_temp; //use for recording or editing
@property(nonatomic,strong)NSString* saveVideoUploadedInfo; //use for Uploaded info

//For iPad or iPhone
@property(nonatomic,assign)BOOL isPhone;
@property(nonatomic,assign)float ratio;

//BookCover
@property(nonatomic,strong)UIImage* coverImage;

//Question Time Info
@property(nonatomic,assign)RecordingTimeInfo recordTimeInfo;

//Quest
@property(nonatomic,strong)NSString* q1;
@property(nonatomic,strong)NSString* q1_sub;
@property(nonatomic,strong)NSString* q2;
@property(nonatomic,strong)NSString* q2_sub;
@property(nonatomic,strong)NSString* q3;
@property(nonatomic,strong)NSString* q3_sub;

//Quest Media
@property(nonatomic,strong)NSString* q1_mp4;
@property(nonatomic,strong)NSString* q1_mp3;
@property(nonatomic,strong)NSString* q2_mp4;
@property(nonatomic,strong)NSString* q2_mp3;
@property(nonatomic,strong)NSString* q3_mp4;
@property(nonatomic,strong)NSString* q3_mp3;

//TalkFile Director
@property(nonatomic,strong)NSString* talkFileRoot;

//UserInfo
@property(nonatomic,strong)NSString* userNick;
@property(nonatomic,assign)long long uid;

//Themes For Edit Vedio
@property(nonatomic,strong)NSArray* themeArr;

@property(nonatomic,strong) NSDictionary* currentTheme;

@property(strong)NSString* bookSegmentFile;

//For run-out //choose language From TalkLocalizedString
@property(nonatomic,strong)NSString* run_out_XML_path; //[TalkLocalizedString(@"language", "") isEqualToString:@"cn"]

@property(strong) NSString* username;

@property(weak)id<TalkVC_Delegate> delegate;

-(void)loadBook:(NSString*)bookPath;

//privte
+ (instancetype)shareLastInstance;

@end
